# Contributor: Oleg Titov <oleg.titov@gmail.com>
# Maintainer: Oleg Titov <oleg.titov@gmail.com>
pkgname=rav1e
pkgver=0.3.3
pkgrel=0
pkgdesc="The fastest and safest AV1 encoder"
url="https://github.com/xiph/rav1e"
arch="all !s390x !mips !mips64" # no cargo for s390x
arch="$arch !x86 !armv7 !armhf" # tests fail on these archies
license="BSD-2-Clause custom"
makedepends="cargo cargo-c nasm openssl-dev"
subpackages="$pkgname-static $pkgname-dev $pkgname-doc $pkgname-libs"
source="$pkgname-$pkgver.tar.gz::https://github.com/xiph/rav1e/archive/v$pkgver.tar.gz"

prepare() {
	default_prepare

	cargo fetch --locked
}

build() {
	cargo build --release --frozen
	cargo cbuild --release --frozen --prefix /usr
}

check() {
	cargo test --release --frozen
}

package() {
	cargo install \
		--locked \
		--path . \
		--root "$pkgdir/usr"

	cargo-cinstall cinstall \
		--release \
		--frozen \
		--prefix /usr \
		--destdir "$pkgdir"

	install -Dm0644 README.md PATENTS -t "$pkgdir/usr/share/doc/rav1e"

	rm "$pkgdir"/usr/.crates.toml
	rm "$pkgdir"/usr/.crates2.json
}

sha512sums="08d12924441d1276f106ae2103932a926f4ffa3bebea390a987766ef5646e4b2211d4473c62133d0307e7f345a341027db27934b8081852a84fc1bc9ec3911c9  rav1e-0.3.3.tar.gz"
